using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;

namespace Business
{
    public enum BoPhanBUSResult
    {
        OK,
        MABPERROR,
        TENBPERROR,
        DAOERROR
    }

    public class clsBoPhanBUS
    {
        //Fields.
        private clsBoPhanDAO boPhanDAO;

        //Constructors.
        public clsBoPhanBUS()
        {
            this.boPhanDAO = new clsBoPhanDAO();
        }

        #region Methods

        public clsBoPhanDTO TimBoPhanCuaNhanVien(String TenDangNhap)
        {
            return boPhanDAO.TimBoPhanCuaNhanVien(TenDangNhap);
        }

        public BoPhanBUSResult KiemTraRong(clsBoPhanDTO obj)
        {
            if (obj.MaBP == "")
                return BoPhanBUSResult.MABPERROR;
            if ((obj.TenBP == ""))
                return BoPhanBUSResult.TENBPERROR;
            return BoPhanBUSResult.OK;
        }

        public DataTable DanhSachBoPhan()
        {
            return this.boPhanDAO.SelectAll();
        }

        public BoPhanBUSResult ThemBoPhan(clsBoPhanDTO obj)
        {
            if (!this.boPhanDAO.Insert(obj))
                return BoPhanBUSResult.DAOERROR;
            return BoPhanBUSResult.OK;
        }

        public BoPhanBUSResult SuaBoPhan(clsBoPhanDTO obj)
        {
            if (!this.boPhanDAO.Update(obj))
                return BoPhanBUSResult.DAOERROR;
            return BoPhanBUSResult.OK;
        }

        public BoPhanBUSResult XoaBoPhan(clsBoPhanDTO obj)
        {
            if (!this.boPhanDAO.Delete(obj))
                return BoPhanBUSResult.DAOERROR;
            return BoPhanBUSResult.OK;
        }
        #endregion
    }
}
